#include<stdio.h>
#include<string.h>
void main()
{
	char a[10];
	int num=0,i;
	gets(a);
	i=strlen(a)-1;
	while(i>=0)
	{
		if(a[i]>='0'&&a[i]<='9')
			num=num*16+a[i]-'0';
		else if(a[i]>='A'&&a[i]<='Z')
			num=num*16+a[i]-'A'+10;
		else if(a[i]>='a'&&a[i]<='z')
			num=num*16+a[i]-'a'+10;
		i--;
	}
	printf("%d\n",num);

}